<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-lx-calendar"></i>拼团管理</el-breadcrumb-item>
				<el-breadcrumb-item><i class="el-icon-lx-calendar"></i>拼团活动</el-breadcrumb-item>
                <el-breadcrumb-item>修改活动</el-breadcrumb-item>
            </el-breadcrumb>
        </div>

		<div class="container">
			<el-row>
				<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
					<el-form ref="form" :model="form" label-width="100px">
						<!-- <el-form-item label="活动id">
							<el-input v-model="form.commodity_id" placeholder="输入活动id"></el-input>
						</el-form-item> -->
						<el-form-item label="拼团金额">
							<el-input v-model="form.money_up" placeholder="输入拼团金额"></el-input>
						</el-form-item>
						<el-form-item label="日利润">
							<el-input v-model="form.day_income" placeholder="输入日利润"></el-input>
						</el-form-item>
						<el-form-item label="月利润">
							<el-input v-model="form.month_income" placeholder="输入月利润"></el-input>
						</el-form-item>
						<el-form-item label="销售开始时间">
							<el-input v-model="form.sell_start_time" placeholder="输入销售开始时间"></el-input>
						</el-form-item>
						<el-form-item label="销售结束时间">
							<el-input v-model="form.sell_end_time" placeholder="输入销售结束时间"></el-input>
						</el-form-item>
						<el-form-item label="未中收益">
							<el-input v-model="form.finalist_income" placeholder="输入未中收益"></el-input>
						</el-form-item>
						<el-form-item label="周期天数">
							<el-input v-model="form.period" placeholder="输入周期天数"></el-input>
						</el-form-item>
						<el-form-item label="直推收益">
							<el-input v-model="form.zhitui_income" placeholder="输入直推收益"></el-input>
						</el-form-item>

                        <el-form-item label="">
                            <el-button :loading="ifload" type="primary" @click="saveData">保存</el-button>
                        </el-form-item>
					</el-form>
				</el-col>
			</el-row>
		</div>

		<loading :ifload="ifload"></loading>
	</div>
</template>

<script type="text/javascript">
	import loading from '@/components/utils/loading';
	export default{
		components:{loading},
		data() {
			return {
				ifload:true,

                commodity_id:'',

				form:{
					commodity_id:"",
				   money_up:'',
				   day_income:'',
				   month_income:'',
				   sell_start_time:'',
				   sell_end_time:'',
				   finalist_income:'',
				   period:'',
				   zhitui_income:''
                },
			}
		},
		created() {
            this.commodity_id = this.$route.query.commodity_id;
			this.$nextTick(()=>{
				this.getData();
			})
		},
		methods: {
			getData() {
                this.ifload = true;
                let param = {commodity_id:this.commodity_id};
                this.$post_('group/group/info',param,(res) => {
                    console.log(res);
                    if(res.code=='0'){
                        this.form.money_up = res.data.money_up;
                        this.form.day_income = res.data.day_income;
                        this.form.month_income = res.data.month_income;
                        this.form.sell_start_time = res.data.sell_start_time;
                        this.form.sell_end_time = res.data.sell_end_time;
                        this.form.finalist_income = res.data.finalist_income;
                        this.form.period = res.data.period;
                        this.form.zhitui_income = res.data.zhitui_income;
                    }
                })
				this.ifload = false;
			},
            //保存数据
            saveData() {
                this.ifload = true;
                this.form.commodity_id = this.commodity_id;
                // this.form.grade = '1';
                this.$post_('group/group/save',this.form,(res) =>{
                    console.log(res);
                    this.ifload = false;
                    if(res.code=='0'){
                        this.$message.success(res.msg);
                        this.$router.back(-1);
                    }else{
                        this.$message.error(res.msg);
                    }
                })
            }
		}
	}
</script>

<style scoped="scoped">
</style>
